cmake_minimum_required(VERSION 3.6)

#set(CMAKE_SYSTEM_NAME Android)
#set(CMAKE_SYSTEM_VERSION 27) # API level
#set(CMAKE_ANDROID_ARCH_ABI arm64-v8a)
#set(CMAKE_ANDROID_NDK D:\\Android\\sdk\\ndk-bundle)
#set(CMAKE_ANDROID_STL_TYPE gnustl_static)
set(BUILD_SHARED_LIBS 0)
set(LEVELDB_BUILD_TESTS 0)
set(LEVELDB_BUILD_BENCHMARKS 0)
set(SNAPPY_BUILD_TESTS 0)
add_subdirectory(snappy)
add_subdirectory(leveldb)


include_directories(
        "leveldb/include"
        "${PROJECT_SOURCE_DIR}"
)


add_library( # Sets the name of the library.
        leveldbcore

        # Sets the library as a shared library.
        SHARED

        # Provides a relative path to your source file(s).
        leveldbjni.cc)


include(CheckLibraryExists)
check_library_exists(snappy snappy_compress "" HAVE_SNAPPY)
check_library_exists(leveldb leveldb::DB "" HAVE_LEVELDB)


#target_sources(snappy)
#target_sources(leveldb)





target_link_libraries( # Specifies the target library.
        leveldbcore

        snappy
        )

target_link_libraries( # Specifies the target library.
        leveldbcore

        leveldb
        )

find_library( # Sets the name of the path variable.
        log-lib

        # Specifies the name of the NDK library that
        # you want CMake to locate.
        log)


target_link_libraries( # Specifies the target library.
        leveldbcore

        # Links the target library to the log library
        # included in the NDK.
        ${log-lib}
         )
